package com.insight;

import com.insight.exceptions.BaseException;
import com.insight.exceptions.GlobalExceptionMapper;
import com.insight.utils.CommonResult;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.jboss.logging.Logger;

/**
 * 测试接口
 */
@Path("/hello")
public class ExampleResource {
    private static final Logger LOG = Logger.getLogger(ExampleResource.class);

    /**
     * 测试接口
     *
     * @return
     */
    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public CommonResult<String> hello() {
        return CommonResult.success("Hello from Quarkus REST");
    }

    @GET
    @Path("/data/{id}")
    @Produces(MediaType.APPLICATION_JSON)
    public CommonResult<String> getData(@PathParam("id") Long id) {
        if (id == null || id <= 0) {
            throw new BaseException(400, "ID参数不合法");
        }
        LOG.info("获取数据: " + id);
        return CommonResult.success("数据: " + id);
    }
}
